<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        
        body {
            background: url(images/1.jpg) no-repeat;
        }
        
        li {
            list-style: none;
        }
        
        .baidu {
            display: flex;
            margin: 100px 30px;
        }
        
        .baidu img {
            width: 400px;
            height: 300px;
        }
    </style>
</head>

<body>
    <ul class="baidu">
        <li><img src="images/1.jpg" alt=""></li>
        <li><img src="images/2.jpg" alt=""></li>
        <li><img src="images/3.jpg" alt=""></li>
        <li><img src="images/4.jpg" alt=""></li>
    </ul>
    <script>
        // 1. 获取元素
        var imgs = document.querySelector('.baidu').querySelectorAll('img');
        // 2. 循环注册事件
        for (var i = 0; i < imgs.length; i++) {
            imgs[i].onclick = function() {
                // this src 就是我们点击图片的路径 
                // 把这个路径 this.src 给body 就可以了
                document.body.style.background = 'url(' + this.src + ')';
            }
        }
    </script>
</body>

</html>